//
//  KSKAAxisView.m
//  DashboardHD
//
//  Created by 楊亜玲 on 17/4/4.
//  Copyright © 2017年 Totyu. All rights reserved.
//

#define LabelHeight 20
#define XAxisNameLeftSpace 150
#define XAxisNameRightSpace 10
#import "KSKAAxisView.h"

@interface KSKAAxisView ()

@property (nonatomic, assign) int labelCount;

@property CGFloat labelHeight;
@property CGFloat labelWidth;

@end

@implementation KSKAAxisView

-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder: aDecoder];
    if (self) {
        
    }
    return self;
}

-(void)layoutSubviews{
    
    // 添加分割线
    CGFloat seperateLineW = self.frame.size.width - XAxisNameRightSpace * 2;
    UILabel *seperateLine = [[UILabel alloc] initWithFrame:CGRectMake(XAxisNameRightSpace, 0, seperateLineW, 1)];
    seperateLine.backgroundColor = KSKAMainColor;
    [self addSubview:seperateLine];
    
    
    // 添加label
    NSMutableArray *tmpArr = [[NSMutableArray alloc] init];
    for (int i = 0 ; i < 24; i ++) {
        [tmpArr addObject:[NSString stringWithFormat:@"%d",i]];
    }
    CGFloat labelW = (self.frame.size.width - XAxisNameLeftSpace - XAxisNameRightSpace)/tmpArr.count;
    
    for (int i=0; i<tmpArr.count; i++) {
        NSString *labelText = tmpArr[i];
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(i * labelW + XAxisNameLeftSpace , 0 , labelW, LabelHeight)];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = labelText;
        [self addSubview:label];
    }
    

    

}



@end
